home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "libsprintf.h"
-
- #if defined(powerc)||defined(__powerc)
- #define kNumLoops 0x00100000
- #else
- #define kNumLoops 0x00001000
- #endif
-
- int main(void){
- char buf[4096];
- unsigned long start,stop,tapple=0L,tlib=0L;
- register long loop;
- long top=kNumLoops;
-
- printf("\n\nSprintf speed tests\n\n");
-
- printf("Performing %ld string expansions\n\n",top);
-
- #if 1
- printf("Beginning Symantec lib test\n");
- sprintf(buf,"Expanding a number %d, a character %c, a C string [%s] and a pascal string [%#s]\n\n",500,'a',"Test String","\pPascal String");
- printf("Buffer expands to [%s], strlen %d\n\n",buf,strlen(buf));
-
- fflush(stdout);
-
- #if 1
- ReadDateTime(&start);
- for (loop=0L;loop<top;loop+=0x00000001){
- sprintf(buf,"Expanding a number %ld, a character %c, a C string [%s] and a pascal string [%#s]\n",loop,'a',"Test String","\pPascal String");
- }
- ReadDateTime(&stop);
- tapple=stop-start;
-
- printf("\nDone with Symantec lib\n\n");
- #endif
-
- #endif
-
- printf("Beginning lib test\n");
- libsprintf(buf,"Expanding a number %ld, a character %c, a C string [%s] and a pascal string [%#s]\n\n",500,'a',"Test String","\pPascal String");
- printf("Buffer expands to [%s], strlen %d\n\n",buf,strlen(buf));
-
- fflush(stdout);
-
- #if 1
- ReadDateTime(&start);
- for (loop=0L;loop<top;loop+=0x00000001){
- libsprintf(buf,"Expanding a number %ld, a character %c, a C string [%s] and a pascal string [%#s]\n",loop,'a',"Test String","\pPascal String");
- }
- ReadDateTime(&stop);
- tlib=stop-start;
-
- printf("\nDone with lib\n\n");
- #endif
-
- printf("Results:\n\tSymantec time %lu\n\tlibsprintf time %lu\n",tapple,tlib);
- fflush(stdout);
-
- return 0;
- }
-
-